package leetcode.editor.cn;

import java.util.List;

//Java：N 叉树的最大深度
public class MaximumDepthOfNAryTree {
    public static void main(String[] args) {
        Solution solution = new MaximumDepthOfNAryTree().new Solution();
        // TO TEST
    }
    //leetcode submit region begin(Prohibit modification and deletion)
/*
// Definition for a Node.
class Node {
    public int val;
    public List<Node> children;

    public Node() {}

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val, List<Node> _children) {
        val = _val;
        children = _children;
    }
};
*/

    class Solution {

        public int maxDepth(Node root) {
            int maxDepth = 0;

            if (root == null) return maxDepth;
            for (Node child : root.children) {
                maxDepth = Math.max(maxDepth, maxDepth(child));
            }
            return maxDepth + 1;
        }

        class Node {
            public int val;
            public List<Node> children;

            public Node() {
            }

            public Node(int _val) {
                val = _val;
            }

            public Node(int _val, List<Node> _children) {
                val = _val;
                children = _children;
            }
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}